Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ssm:GetParametersByPath to SSMParameterReadPolicy #1084

Merged
merged 1 commit into from Aug 15, 2019

Conversation

53ningen
Copy link
Contributor

Issue #, if available:
#1071

Description of changes:
add ssm:GetParametersByPath to SSMParameterReadPolicy

Description of how you validated changes:

  • make pr
  • verified transformed template in the steps written in DEVELOPMENT_GUIDE

using this SAM template

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Globals:
  Function:
    Runtime: python3.7

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: worker/
      Handler: app.lambda_handler
      Policies:
        - SSMParameterReadPolicy:
            ParameterName: '*'

Then I got expected transformed template like this:

          {
            "PolicyName": "HelloWorldFunctionRolePolicy0", 
            "PolicyDocument": {
              "Statement": [
                {
                  "Action": [
                    "ssm:DescribeParameters"
                  ], 
                  "Resource": "*", 
                  "Effect": "Allow"
                }, 
                {
                  "Action": [
                    "ssm:GetParameters", 
                    "ssm:GetParameter", 
                    "ssm:GetParametersByPath"
                  ], 
                  "Resource": {
                    "Fn::Sub": [
                      "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${parameterName}", 
                      {
                        "parameterName": "*"
                      }
                    ]
                  }, 
                  "Effect": "Allow"
                }
              ]
            }
          }

Also confirmed to execute the function below successfully:

# -*- coding: utf-8 -*-

import boto3

ssm = boto3.client('ssm')


def lambda_handler(_, __):
    res = ssm.get_parameters_by_path(
        Path='/',
    )
    print(res)

Checklist:

  • Write/update tests
  • make pr passes
  • [-] Update documentation
  • Verify transformed template deploys and application functions as expected
  • [-] Add/update example to examples/2016-10-31

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@keetonian keetonian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@jlhood jlhood merged commit e371e52 into aws:develop Aug 15, 2019
@53ningen 53ningen deleted the ssm-parameter-read-policy branch August 16, 2019 03:37
@praneetap praneetap mentioned this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants